package org.mango.util;

import com.alibaba.fastjson.JSONObject;
import org.mango.bean.User;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by meigang on 17/11/8.
 */
public class UserUtil {
    /**
     * 获取登录用户
     * @param req
     * @return
     */
    public static User getSessionUser(HttpServletRequest req){
        String userJsonStr = (String) req.getSession().getAttribute(KeyUtil.USER_SESSION_KEY);
        return JSONObject.parseObject(userJsonStr,User.class);
    }
}
